package com.sojson.util.pwd;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * 密码工具类
 * 
 * @author liu
 * @date 2021-05-18
 */
public class PwdUtil {

    /**
     * 密码加密
     * 
     * @param pwd 密码
     * @return
     * @throws Exception
     */
    public static String encryptionPwd(String pwd) {
        return new BCryptPasswordEncoder().encode(pwd);
    }

    /**
     * 判断密码是否正确
     * 
     * @param pwdParam  前段传过来的密码
     * @param pwd       数据库获取的密码
     * @return
     * @throws Exception
     */
    public static boolean matchesPwd(String pwdParam, String pwd) {
        return new BCryptPasswordEncoder().matches(pwdParam, pwd);
    }

}